<?php

/**
 * InfractionController
 */

class Application_Controllers_InfractionController{
         function __construct($action) {
        switch ($action) {
            case 'show':
               $this->_show();
                break;
            case 'query':
                $this->_query();
                break;
            case 'showinsert':
                $this->_showInsert();
                break;
            case 'insert':
                $this->insert();
                break;
            case 'modify':
              $this->_modify();
                break;
            default:
               $this->_query();
                break;
        }
    }
    
    private function _showInsert(){     
        $viewInfraction = new Application_Views_InfractionView();
        $viewInfraction->formInsert();        
    }
    
    private function set(Application_Models_InfractionModel &$model){
        $model->set_idInfraction($_POST['infraccion']);
        $model->set_idLicensePlate($_POST['placa']);
        $model->set_idType($_POST['tipo']);
        $model->set_nameOffender($_POST['infractor']);
        $model->set_infractionDate($_POST['fechaInfraccion']);
        $model->set_insteadInfraction($_POST['lugar']);
        $model->set_cost($_POST['precio']);
        $model->set_description($_POST['descripcion']);
      
    }
    
    public function insert(){     
        $modelInfraction = new Application_Models_InfractionModel();
        $this->set($modelInfraction);

        //die($modelOwner->get_idOwner());        
        $modelInfraction->insertInfraction();        
    }
    
    private function _show(){
        $modelVehicle = new Application_Models_InfractionModel();        
        $modelVehicle->showInfraction1();
    }
    
    private function _modify(){
        $modelInfraction = new Application_Models_InfractionModel();
         $this->set($modelInfraction);
        $modelInfraction->updateInfraction();
    }

}